diff options
Diffstat (limited to 'catalog-model/src')
24 files changed, 350 insertions, 1068 deletions
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<ComponentInstanceProperty> 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<ComponentInstanceProperty> getProperties() { - return properties; - } - - public void setProperties(List<ComponentInstanceProperty> properties) { - this.properties = properties; - } - public void updateCapabilityProperties(CapabilityDefinition capabilityDefinition) { if(CollectionUtils.isNotEmpty(getProperties()) && capabilityDefinition!= null && CollectionUtils.isNotEmpty(capabilityDefinition.getProperties())){ Map<String, ComponentInstanceProperty> 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<String, PropertyDefinition> properties; - public String getDerivedFrom() { - return derivedFrom; - } - - public void setDerivedFrom(String derivedFrom) { - this.derivedFrom = derivedFrom; - } - - public Map<String, PropertyDefinition> getProperties() { - return properties; - } - - public void setProperties(Map<String, PropertyDefinition> 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<RequirementCapabilityRelDef> componentInstancesRelations; private Map<String, List<ComponentInstanceInput>> componentInstancesInputs; private Map<String, List<ComponentInstanceProperty>> componentInstancesProperties; - private Map<String, List<ComponentInstanceProperty>> componentInstancesAttributes; + private Map<String, List<ComponentInstanceAttribute>> componentInstancesAttributes; private Map<String, List<CapabilityDefinition>> capabilities; private Map<String, List<RequirementDefinition>> requirements; private Map<String, List<ComponentInstanceInterface>> 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<String> path; + + private List<PropertyRule> 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<PropertyRule> 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<String, String> derivedFromMapOfIdToName; - private List<PropertyDefinition> attributes; + private List<AttributeDataDefinition> 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<String> derivedFrom; private List<String> derivedList; private Map<String, String> derivedFromMapOfIdToName; - private Map<String, PropertyDataDefinition> attributes; + private Map<String, AttributeDataDefinition> attributes; private Map<String, InterfaceDataDefinition> 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<String, PropertyDataDefinition> inputs; private Map<String, MapPropertiesDataDefinition> instInputs; private Map<String, ? extends ToscaDataDefinition> heatParameters; - private Map<String, MapPropertiesDataDefinition> instAttributes; + private Map<String, MapAttributesDataDefinition> instAttributes; private Map<String, MapPropertiesDataDefinition> instProperties; private Map<String, GroupDataDefinition> groups; private Map<String, PolicyDataDefinition> policies; @@ -58,238 +80,61 @@ public class TopologyTemplate extends ToscaElement{ private Map<String, MapInterfaceInstanceDataDefinition> instInterfaces; private Map<String, MapInterfaceDataDefinition> componentInstInterfaces; private Map<String, DataTypeDataDefinition> dataTypes; - private Map<String, CINodeFilterDataDefinition> nodeFilterComponents; private Map<String, SubstitutionFilterDataDefinition> substitutionFilterDataDefinitionMap; + //Component Instances External References (instanceId -> ExternalRefsMap) //----------------------------------------------------------------------- private Map<String, MapComponentInstanceExternalRefs> mapComponentInstancesExternalRefs; - - public Map<String, MapComponentInstanceExternalRefs> getMapComponentInstancesExternalRefs() { - return this.mapComponentInstancesExternalRefs; - } - - public void setComponentInstancesExternalRefs(Map<String, MapComponentInstanceExternalRefs> mapComponentInstancesExternalRefs) { - this.mapComponentInstancesExternalRefs = mapComponentInstancesExternalRefs; - } //----------------------------------------------------------------------- - public Map<String, InterfaceDataDefinition> getInterfaces() { - return interfaces; - } - - public void setInterfaces(Map<String, InterfaceDataDefinition> interfaces) { - this.interfaces = interfaces; - } - - public Map<String, MapInterfaceInstanceDataDefinition> getInstInterfaces() { - return instInterfaces; - } - - public void setInstInterfaces( - Map<String, MapInterfaceInstanceDataDefinition> 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<String, MapInterfaceDataDefinition> getComponentInstInterfaces() { - return componentInstInterfaces; - } - - public void setComponentInstInterfaces( - Map<String, MapInterfaceDataDefinition> 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<String, PropertyDataDefinition> getInputs() { - return inputs; - } - public void setInputs(Map<String, PropertyDataDefinition> inputs) { - this.inputs = inputs; - } - public Map<String, MapPropertiesDataDefinition> getInstInputs() { - return instInputs; - } - public void setInstInputs(Map<String, MapPropertiesDataDefinition> instInputs) { - this.instInputs = instInputs; - } - public Map<String, ? extends ToscaDataDefinition> getHeatParameters() { - return heatParameters; - } - public void setHeatParameters(Map<String, ? extends ToscaDataDefinition> heatParameters) { - this.heatParameters = heatParameters; - } - public Map<String, MapPropertiesDataDefinition> getInstAttributes() { - return instAttributes; - } - public void setInstAttributes(Map<String, MapPropertiesDataDefinition> instAttributes) { - this.instAttributes = instAttributes; - } - public Map<String, MapPropertiesDataDefinition> getInstProperties() { - return instProperties; - } - public void setInstProperties(Map<String, MapPropertiesDataDefinition> instProperties) { - this.instProperties = instProperties; - } - public Map<String, GroupDataDefinition> getGroups() { - return groups; - } - public void setGroups(Map<String, GroupDataDefinition> groups) { - this.groups = groups; - } - public Map<String, PolicyDataDefinition> getPolicies() { - return policies; - } - public void setPolicies(Map<String, PolicyDataDefinition> policies) { - this.policies = policies; - } - public Map<String, MapGroupsDataDefinition> getInstGroups() { - return instGroups; - } - public void setInstGroups(Map<String, MapGroupsDataDefinition> instGroups) { - this.instGroups = instGroups; - } - public Map<String, ArtifactDataDefinition> getServiceApiArtifacts() { - return serviceApiArtifacts; - } - public void setServiceApiArtifacts(Map<String, ArtifactDataDefinition> serviceApiArtifacts) { - this.serviceApiArtifacts = serviceApiArtifacts; - } - public Map<String, CompositionDataDefinition> getCompositions() { - return compositions; - } - public void setCompositions(Map<String, CompositionDataDefinition> compositions) { - this.compositions = compositions; - } - public Map<String, MapListCapabilityDataDefinition> getCalculatedCapabilities() { - return calculatedCapabilities; - } - public void setCalculatedCapabilities(Map<String, MapListCapabilityDataDefinition> calculatedCapabilities) { - this.calculatedCapabilities = calculatedCapabilities; - } - public Map<String, MapListRequirementDataDefinition> getCalculatedRequirements() { - return calculatedRequirements; - } - public void setCalculatedRequirements(Map<String, MapListRequirementDataDefinition> calculatedRequirements) { - this.calculatedRequirements = calculatedRequirements; - } - public Map<String, MapListCapabilityDataDefinition> getFullfilledCapabilities() { - return fullfilledCapabilities; - } - public void setFullfilledCapabilities(Map<String, MapListCapabilityDataDefinition> fullfilledCapabilities) { - this.fullfilledCapabilities = fullfilledCapabilities; - } - public Map<String, MapListRequirementDataDefinition> getFullfilledRequirements() { - return fullfilledRequirements; - } - public void setFullfilledRequirements(Map<String, MapListRequirementDataDefinition> fullfilledRequirements) { - this.fullfilledRequirements = fullfilledRequirements; - } - - public Map<String, MapArtifactDataDefinition> getInstDeploymentArtifacts() { - return instDeploymentArtifacts; - } - public void setInstDeploymentArtifacts(Map<String, MapArtifactDataDefinition> instDeploymentArtifacts) { - this.instDeploymentArtifacts = instDeploymentArtifacts; - } - - public Map<String, MapCapabilityProperty> getCalculatedCapabilitiesProperties() { - return calculatedCapabilitiesProperties; - } - public void setCalculatedCapabilitiesProperties(Map<String, MapCapabilityProperty> calculatedCapabilitiesProperties) { - this.calculatedCapabilitiesProperties = calculatedCapabilitiesProperties; - } - - public Map<String, MapArtifactDataDefinition> getInstanceArtifacts() { - return instanceArtifacts; - } - public void setInstanceArtifacts(Map<String, MapArtifactDataDefinition> instanceArtifacts) { - this.instanceArtifacts = instanceArtifacts; - } - - public Map<String, ForwardingPathDataDefinition> getForwardingPaths() { - return forwardingPaths; - } - - public void setForwardingPaths(Map<String, ForwardingPathDataDefinition> forwardingPaths) { - this.forwardingPaths = forwardingPaths; - } - - public Map<String, CINodeFilterDataDefinition> getNodeFilterComponents() { - return nodeFilterComponents; - } - - public void setNodeFilterComponents(Map<String, CINodeFilterDataDefinition> nodeFilters) { - this.nodeFilterComponents = nodeFilters; - } - - public Map<String, SubstitutionFilterDataDefinition> getSubstitutionFilterDataDefinitionMap() { - return substitutionFilterDataDefinitionMap; - } - - public void setSubstitutionFilterDataDefinitionMap( - Map<String, SubstitutionFilterDataDefinition> substitutionFilterDataDefinitionMap) { - this.substitutionFilterDataDefinitionMap = substitutionFilterDataDefinitionMap; - } - - /** - * Gets data types. - * @return Current data types. - */ - public Map<String, DataTypeDataDefinition> getDataTypes() { - return dataTypes; - } - /** - * Sets data types. - * @param dataTypes New data types. - */ - public void setDataTypes(Map<String, DataTypeDataDefinition> 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<String, ComponentInstanceDataDefinition> getComponentInstances() { Map<String, ComponentInstanceDataDefinition> 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<String, ComponentInstanceDataDefinition> 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<String, RelationshipInstDataDefinition> getRelations() { Map<String, RelationshipInstDataDefinition> 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<String> 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<String> 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<Map<String, PropertyDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.ATTRIBUTES); + Either<Map<String, AttributeDataDefinition>, 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<GraphVertex> derivedResources) { // Note : currently only one derived supported!!!! - Either<Map<String, PropertyDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, EdgeLabelEnum.ATTRIBUTES); + Either<Map<String, AttributeDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, EdgeLabelEnum.ATTRIBUTES); if (dataFromDerived.isRight()) { return dataFromDerived.right().value(); } - Map<String, PropertyDataDefinition> attributesAll = dataFromDerived.left().value(); + Map<String, AttributeDataDefinition> attributesAll = dataFromDerived.left().value(); - Map<String, PropertyDataDefinition> attributes = nodeType.getAttributes(); + Map<String, AttributeDataDefinition> 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<String, MapPropertiesDataDefinition> instAttr = topologyTemplate.getInstAttributes(); + Map<String, MapAttributesDataDefinition> 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<String, MapPropertiesDataDefinition> instAttr) { + public StorageOperationStatus associateInstAttributeToComponent(GraphVertex nodeTypeVertex, Map<String, MapAttributesDataDefinition> instAttr) { if (instAttr != null && !instAttr.isEmpty()) { Either<GraphVertex, StorageOperationStatus> 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<GraphVertex, StorageOperationStatus> getComponentByLabelAndId(String uniqueId, ToscaElementTypeEnum nodeType, JsonParseFlagEnum parseFlag) { Map<GraphPropertyEnum, Object> 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<String, Object> 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<String, AttributeDataDefinition> getAttributesFromComponentV(final GraphVertex componentV) { + final Map<String, Object> jsonMetada = componentV.getMetadataJson(); + final Map<String, AttributeDataDefinition> attributeDataDefinitionMap = new HashMap<>(); + if (MapUtils.isNotEmpty(jsonMetada)) { + final Object attributes = jsonMetada.get(ToscaTagNamesEnum.ATTRIBUTES.getElementName()); + if (attributes instanceof Map) { + final Map<String, Object> map = (Map<String, Object>) attributes; + attributeDataDefinitionMap.putAll(map.values().stream().map(attributeMap -> { + final AttributeDefinition attributeDef = new AttributeDefinition(); + final String name = (String) ((Map<String, Object>) attributeMap).get("name"); + attributeDef.setName(name); + final String type = (String) ((Map<String, Object>) attributeMap).get("type"); + attributeDef.setType(type); + final String description = (String) ((Map<String, Object>) attributeMap).get("description"); + attributeDef.setDescription(description); + return attributeDef; + }).collect(Collectors.toMap(AttributeDefinition::getName, a -> a))); + } + } + return attributeDataDefinitionMap; + } + protected JanusGraphOperationStatus setResourceCategoryFromGraphV(Vertex vertex, CatalogComponent catalogComponent) { List<CategoryDefinition> 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<ResourceTypeEnum> 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<String, List<PropertyDefinition>> instArttributes, Component component) { + public StorageOperationStatus associateInstAttributeToComponentToInstances(Map<String, List<AttributeDataDefinition>> instArttributes, Component component) { Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao.getVertexById(component.getUniqueId(), JsonParseFlagEnum.NoParse); if (getVertexEither.isRight()) { @@ -1482,24 +1482,24 @@ public class ToscaOperationFacade { } GraphVertex vertex = getVertexEither.left().value(); - Map<String, MapPropertiesDataDefinition> instAttr = new HashMap<>(); + Map<String, MapAttributesDataDefinition> instAttr = new HashMap<>(); if (instArttributes != null) { - MapPropertiesDataDefinition attributesMap; - for (Entry<String, List<PropertyDefinition>> 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<String, List<AttributeDataDefinition>> entry : instArttributes.entrySet()) { + final List<AttributeDataDefinition> value = entry.getValue(); + attributesMap = new MapAttributesDataDefinition(); + attributesMap.setMapToscaDataDefinition(value.stream().map(AttributeDataDefinition::new).collect(Collectors.toMap(AttributeDataDefinition::getName, e -> e))); instAttr.put(entry.getKey(), attributesMap); } } setComponentInstanceAttributesOnComponent(component, instAttr); return topologyTemplateOperation.associateInstAttributeToComponent(vertex, instAttr); - } // endregion - private void setComponentInstanceAttributesOnComponent(Component resource, Map<String, MapPropertiesDataDefinition> instAttr) { - Map<String, List<ComponentInstanceProperty>> componentInstancesAttributes = resource.getComponentInstancesAttributes(); + private void setComponentInstanceAttributesOnComponent(Component resource, Map<String, MapAttributesDataDefinition> instAttr) { + Map<String, List<ComponentInstanceAttribute>> componentInstancesAttributes = resource.getComponentInstancesAttributes(); if (componentInstancesAttributes == null) componentInstancesAttributes = new HashMap<>(); componentInstancesAttributes.putAll(ModelConverter.getComponentInstancesAttributes(instAttr)); @@ -2382,11 +2382,10 @@ public class ToscaOperationFacade { } - - public Either<PropertyDefinition, StorageOperationStatus> addAttributeOfResource(Component component, PropertyDefinition newAttributeDef) { + public Either<AttributeDataDefinition, StorageOperationStatus> addAttributeOfResource(Component component, AttributeDataDefinition newAttributeDef) { Either<Component, StorageOperationStatus> getUpdatedComponentRes = null; - Either<PropertyDefinition, StorageOperationStatus> result = null; + Either<AttributeDataDefinition, StorageOperationStatus> 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<PropertyDefinition> newAttribute = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny(); + Optional<AttributeDataDefinition> newAttribute = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny(); if (newAttribute.isPresent()) { result = Either.left(newAttribute.get()); } else { @@ -2418,10 +2417,10 @@ public class ToscaOperationFacade { return result; } - public Either<PropertyDefinition, StorageOperationStatus> updateAttributeOfResource(Component component, PropertyDefinition newAttributeDef) { + public Either<AttributeDataDefinition, StorageOperationStatus> updateAttributeOfResource(Component component, AttributeDataDefinition newAttributeDef) { Either<Component, StorageOperationStatus> getUpdatedComponentRes = null; - Either<PropertyDefinition, StorageOperationStatus> result = null; + Either<AttributeDataDefinition, StorageOperationStatus> 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<PropertyDefinition> newProperty = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny(); + Optional<AttributeDataDefinition> newProperty = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny(); if (newProperty.isPresent()) { result = Either.left(newProperty.get()); } else { @@ -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<String, PropertyDataDefinition> attributes = nodeType.getAttributes(); + Map<String, AttributeDataDefinition> attributes = nodeType.getAttributes(); if (attributes != null) { - List<PropertyDefinition> attrs = attributes.values().stream().map(dataDef -> ModelConverter.fromDataDefinition(resource.getUniqueId(), dataDef)).collect(Collectors.toList()); + final List<AttributeDataDefinition> 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<PropertyDefinition> attributes = component.getAttributes(); + List<AttributeDataDefinition> attributes = component.getAttributes(); if (attributes != null) { - Map<String, PropertyDataDefinition> attrsByName = attributes.stream().map(PropertyDataDefinition::new).collect(Collectors.toMap(PropertyDataDefinition::getName, Function.identity())); + Map<String, AttributeDataDefinition> attrsByName = attributes.stream() + .collect(Collectors.toMap(AttributeDataDefinition::getName, Function.identity())); nodeType.setAttributes(attrsByName); } } @@ -1434,8 +1438,10 @@ public class ModelConverter { for (Entry<String, MapPropertiesDataDefinition> entry : topologyTemplate.getInstProperties().entrySet()) { if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) { String key = entry.getKey(); - List<ComponentInstanceProperty> componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream().map(e -> new ComponentInstanceProperty(new PropertyDefinition(e.getValue()))) - .collect(Collectors.toList()); + List<ComponentInstanceProperty> 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<String, List<ComponentInstanceProperty>> getComponentInstancesAttributes(Map<String, MapPropertiesDataDefinition> mapPropertiesDataDefinition) { - Map<String, List<ComponentInstanceProperty>> attributes = new HashMap<>(); - for (Map.Entry<String, MapPropertiesDataDefinition> entry : mapPropertiesDataDefinition.entrySet()) { + public static Map<String, List<ComponentInstanceAttribute>> getComponentInstancesAttributes( + Map<String, MapAttributesDataDefinition> mapAttributesDataDefinitionMap) { + Map<String, List<ComponentInstanceAttribute>> attributes = new HashMap<>(); + for (Map.Entry<String, MapAttributesDataDefinition> entry : mapAttributesDataDefinitionMap.entrySet()) { if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) { String key = entry.getKey(); - List<ComponentInstanceProperty> componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream().map(e -> new ComponentInstanceProperty(new ComponentInstanceProperty(e.getValue()))) - .collect(Collectors.toList()); + List<ComponentInstanceAttribute> 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<String, List<ComponentInstanceProperty>> attributes = new HashMap<>(); - for (Map.Entry<String, MapPropertiesDataDefinition> entry : topologyTemplate.getInstAttributes().entrySet()) { + Map<String, List<ComponentInstanceAttribute>> attributes = new HashMap<>(); + for (Map.Entry<String, MapAttributesDataDefinition> entry : topologyTemplate.getInstAttributes() + .entrySet()) { if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) { String key = entry.getKey(); - List<ComponentInstanceProperty> componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream().map(e -> new ComponentInstanceProperty(new ComponentInstanceProperty(e.getValue()))) - .collect(Collectors.toList()); + List<ComponentInstanceAttribute> 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<String, List<ComponentInstanceProperty>> entry : component.getComponentInstancesAttributes().entrySet()) { - attributesMap = new MapPropertiesDataDefinition(); + MapAttributesDataDefinition attributesMap; + for (Entry<String, List<ComponentInstanceAttribute>> 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<RequirementCapabilityRelDef> componentInstancesRelations; private Map<String, List<ComponentInstanceInput>> componentInstancesInputs; private Map<String, List<ComponentInstanceProperty>> componentInstancesProperties; - private Map<String, List<ComponentInstanceProperty>> componentInstancesAttributes; + private Map<String, List<ComponentInstanceAttribute>> componentInstancesAttributes; private Map<String, List<CapabilityDefinition>> capabilities; private List<PolicyDefinition> policies; private Map<String, List<RequirementDefinition>> 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<PropertyDefinition> properties; - private List<PropertyDefinition> attributes; + private List<AttributeDataDefinition> attributes; private Map<String, InterfaceDefinition> 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; @@ -46,27 +41,6 @@ public class CapabilityDefinitionTest { 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); CapabilityDefinition capabilityDefinition = createCapabilityDefinition(equalConstraint); 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; @@ -42,24 +39,6 @@ public class CapabilityTypeDefinitionTest { 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(); CapabilityTypeDataDefinition capabilityTypeDataDefinition = new CapabilityTypeDataDefinition(); 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; @@ -35,17 +33,6 @@ public class ComponentInstanceInterfaceBeanTest { 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); ComponentInstanceInterface componentInstanceInterface1 = new ComponentInstanceInterface(INTERFACE_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; @@ -45,66 +46,6 @@ public class ResourceTest extends ModelConfDependentTest { } @Test - public void testGetProperties() throws Exception { - Resource testSubject; - List<PropertyDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getProperties(); - } - - @Test - public void testSetProperties() throws Exception { - Resource testSubject; - List<PropertyDefinition> properties = null; - - // default test - testSubject = createTestSubject(); - testSubject.setProperties(properties); - } - - @Test - public void testGetAttributes() throws Exception { - Resource testSubject; - List<PropertyDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getAttributes(); - } - - @Test - public void testSetAttributes() throws Exception { - Resource testSubject; - List<PropertyDefinition> attributes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setAttributes(attributes); - } - - @Test - public void testGetInterfaces() throws Exception { - Resource testSubject; - Map<String, InterfaceDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInterfaces(); - } - - @Test - public void testSetInterfaces() throws Exception { - Resource testSubject; - Map<String, InterfaceDefinition> interfaces = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInterfaces(interfaces); - } - - @Test public void testIsAbstract() throws Exception { Resource testSubject; Boolean result; @@ -165,47 +106,6 @@ public class ResourceTest extends ModelConfDependentTest { } @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; String result; 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<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDerivedList(); - } - - - @Test - public void testSetDerivedList() throws Exception { - NodeType testSubject; - List<String> derivedList = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDerivedList(derivedList); - } - - - @Test - public void testGetDerivedFrom() throws Exception { - NodeType testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDerivedFrom(); - } - - - @Test - public void testSetDerivedFrom() throws Exception { - NodeType testSubject; - List<String> derivedFrom = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDerivedFrom(derivedFrom); - } - - - @Test - public void testGetAttributes() throws Exception { - NodeType testSubject; - Map<String, PropertyDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getAttributes(); - } - - - @Test - public void testSetAttributes() throws Exception { - NodeType testSubject; - Map<String, PropertyDataDefinition> attributes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setAttributes(attributes); - } - - - @Test - public void testGetCapabilties() throws Exception { - NodeType testSubject; - Map<String, ListCapabilityDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCapabilities(); - } - - - @Test - public void testSetCapabilties() throws Exception { - NodeType testSubject; - Map<String, ListCapabilityDataDefinition> capabilties = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCapabilities(capabilties); - } - - - @Test - public void testGetRequirements() throws Exception { - NodeType testSubject; - Map<String, ListRequirementDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRequirements(); - } - - - @Test - public void testSetRequirements() throws Exception { - NodeType testSubject; - Map<String, ListRequirementDataDefinition> requirements = null; - - // default test - testSubject = createTestSubject(); - testSubject.setRequirements(requirements); - } - - - @Test - public void testGetCapabiltiesProperties() throws Exception { - NodeType testSubject; - Map<String, MapPropertiesDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCapabilitiesProperties(); - } - - @Test - public void testSetCapabiltiesProperties() throws Exception { + public void testCTOR() throws Exception { NodeType testSubject; - Map<String, MapPropertiesDataDefinition> 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<String, InterfaceDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInterfaceArtifacts(); - } - - - @Test - public void testSetInterfaceArtifacts() throws Exception { - NodeType testSubject; - Map<String, InterfaceDataDefinition> 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<String, PropertyDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInputs(); - } - - - @Test - public void testSetInputs() throws Exception { - TopologyTemplate testSubject; - Map<String, PropertyDataDefinition> inputs = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInputs(inputs); - } - - - @Test - public void testGetInstInputs() throws Exception { - TopologyTemplate testSubject; - Map<String, MapPropertiesDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInstInputs(); - } - - - @Test - public void testSetInstInputs() throws Exception { - TopologyTemplate testSubject; - Map<String, MapPropertiesDataDefinition> instInputs = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInstInputs(instInputs); - } - - - @Test - public void testGetHeatParameters() throws Exception { - TopologyTemplate testSubject; - Map<String, ? extends ToscaDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getHeatParameters(); - } - - - @Test - public void testSetHeatParameters() throws Exception { - TopologyTemplate testSubject; - Map<String, ? extends ToscaDataDefinition> heatParameters = null; - - // default test - testSubject = createTestSubject(); - testSubject.setHeatParameters(heatParameters); - } - - - @Test - public void testGetInstAttributes() throws Exception { - TopologyTemplate testSubject; - Map<String, MapPropertiesDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInstAttributes(); - } - - - @Test - public void testSetInstAttributes() throws Exception { - TopologyTemplate testSubject; - Map<String, MapPropertiesDataDefinition> instAttributes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInstAttributes(instAttributes); - } - - - @Test - public void testGetInstProperties() throws Exception { - TopologyTemplate testSubject; - Map<String, MapPropertiesDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInstProperties(); - } - - - @Test - public void testSetInstProperties() throws Exception { - TopologyTemplate testSubject; - Map<String, MapPropertiesDataDefinition> instProperties = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInstProperties(instProperties); - } - - - @Test - public void testGetGroups() throws Exception { - TopologyTemplate testSubject; - Map<String, GroupDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getGroups(); - } - - - @Test - public void testSetGroups() throws Exception { - TopologyTemplate testSubject; - Map<String, GroupDataDefinition> groups = null; - - // default test - testSubject = createTestSubject(); - testSubject.setGroups(groups); - } - - - @Test - public void testGetInstGroups() throws Exception { - TopologyTemplate testSubject; - Map<String, MapGroupsDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInstGroups(); - } - - - @Test - public void testSetInstGroups() throws Exception { - TopologyTemplate testSubject; - Map<String, MapGroupsDataDefinition> instGroups = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInstGroups(instGroups); - } - - - @Test - public void testGetServiceApiArtifacts() throws Exception { - TopologyTemplate testSubject; - Map<String, ArtifactDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getServiceApiArtifacts(); - } - - - @Test - public void testSetServiceApiArtifacts() throws Exception { - TopologyTemplate testSubject; - Map<String, ArtifactDataDefinition> serviceApiArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setServiceApiArtifacts(serviceApiArtifacts); - } - - - @Test - public void testGetCompositions() throws Exception { - TopologyTemplate testSubject; - Map<String, CompositionDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCompositions(); - } - - - @Test - public void testSetCompositions() throws Exception { - TopologyTemplate testSubject; - Map<String, CompositionDataDefinition> compositions = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCompositions(compositions); - } - - - @Test - public void testGetCalculatedCapabilities() throws Exception { - TopologyTemplate testSubject; - Map<String, MapListCapabilityDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCalculatedCapabilities(); - } - - - @Test - public void testSetCalculatedCapabilities() throws Exception { - TopologyTemplate testSubject; - Map<String, MapListCapabilityDataDefinition> calculatedCapabilities = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCalculatedCapabilities(calculatedCapabilities); - } - - - @Test - public void testGetCalculatedRequirements() throws Exception { - TopologyTemplate testSubject; - Map<String, MapListRequirementDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCalculatedRequirements(); - } - - - @Test - public void testSetCalculatedRequirements() throws Exception { - TopologyTemplate testSubject; - Map<String, MapListRequirementDataDefinition> calculatedRequirements = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCalculatedRequirements(calculatedRequirements); - } - - - @Test - public void testGetFullfilledCapabilities() throws Exception { - TopologyTemplate testSubject; - Map<String, MapListCapabilityDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getFullfilledCapabilities(); - } - - - @Test - public void testSetFullfilledCapabilities() throws Exception { - TopologyTemplate testSubject; - Map<String, MapListCapabilityDataDefinition> fullfilledCapabilities = null; - - // default test - testSubject = createTestSubject(); - testSubject.setFullfilledCapabilities(fullfilledCapabilities); - } - - - @Test - public void testGetFullfilledRequirements() throws Exception { - TopologyTemplate testSubject; - Map<String, MapListRequirementDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getFullfilledRequirements(); - } - - - @Test - public void testSetFullfilledRequirements() throws Exception { - TopologyTemplate testSubject; - Map<String, MapListRequirementDataDefinition> fullfilledRequirements = null; - - // default test - testSubject = createTestSubject(); - testSubject.setFullfilledRequirements(fullfilledRequirements); - } - - - @Test - public void testGetInstDeploymentArtifacts() throws Exception { - TopologyTemplate testSubject; - Map<String, MapArtifactDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInstDeploymentArtifacts(); - } - - - @Test - public void testSetInstDeploymentArtifacts() throws Exception { - TopologyTemplate testSubject; - Map<String, MapArtifactDataDefinition> instDeploymentArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInstDeploymentArtifacts(instDeploymentArtifacts); - } - - - @Test - public void testGetCalculatedCapabilitiesProperties() throws Exception { - TopologyTemplate testSubject; - Map<String, MapCapabilityProperty> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCalculatedCapabilitiesProperties(); - } - - - @Test - public void testSetCalculatedCapabilitiesProperties() throws Exception { - TopologyTemplate testSubject; - Map<String, MapCapabilityProperty> calculatedCapabilitiesProperties = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCalculatedCapabilitiesProperties(calculatedCapabilitiesProperties); - } - - - @Test - public void testGetInstanceArtifacts() throws Exception { - TopologyTemplate testSubject; - Map<String, MapArtifactDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInstanceArtifacts(); - } - - - @Test - public void testSetInstanceArtifacts() throws Exception { - TopologyTemplate testSubject; - Map<String, MapArtifactDataDefinition> instanceArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInstanceArtifacts(instanceArtifacts); - } - - - @Test - public void testGetDataTypes() throws Exception { - TopologyTemplate testSubject; - Map<String, DataTypeDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDataTypes(); - } - - - @Test - public void testSetDataTypes() throws Exception { - TopologyTemplate testSubject; - Map<String, DataTypeDataDefinition> 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; |