From 29ef7edbf694dea1a33a7ddd97b7250d2ec1f61e Mon Sep 17 00:00:00 2001 From: vasraz Date: Tue, 24 Mar 2020 12:29:04 +0000 Subject: Increase test coverage Change-Id: I90606d768c55ad13aa9df62bc4d3f533206db1bc Signed-off-by: Vasyl Razinkov Issue-ID: SDC-2833 --- .../java/org/openecomp/sdc/be/model/Component.java | 712 +++++---------------- .../java/org/openecomp/sdc/be/model/Product.java | 9 +- .../sdc/be/model/RequirementDefinition.java | 6 +- .../java/org/openecomp/sdc/be/model/Service.java | 276 ++++---- 4 files changed, 318 insertions(+), 685 deletions(-) (limited to 'catalog-model/src/main/java/org') 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 3cea34fdef..38f2f36ae2 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 @@ -36,6 +36,9 @@ import java.util.Objects; import java.util.Optional; import java.util.function.Predicate; import java.util.stream.Collectors; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; import org.apache.commons.collections.MapUtils; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.utils.MapUtil; @@ -52,146 +55,64 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElementTypeEnum; import org.openecomp.sdc.common.api.ArtifactTypeEnum; import org.openecomp.sdc.common.log.api.ILogConfiguration; +@Getter +@Setter +@EqualsAndHashCode public abstract class Component implements PropertiesOwner { - private ComponentMetadataDefinition componentMetadataDefinition; - private Map artifacts; - private Map deploymentArtifacts; - private Map toscaArtifacts; - private List categories; - private List componentInstances; - private List componentInstancesRelations; - private Map> componentInstancesInputs; - private Map> componentInstancesProperties; - private Map> componentInstancesAttributes; - private Map> capabilities; - private Map> requirements; - private Map> componentInstancesInterfaces; - private List inputs; - private List groups; - private Map policies; - private String derivedFromGenericType; - private String derivedFromGenericVersion; - private String toscaType; - protected List additionalInformation; - private Map nodeFilterComponents; - private Map> nodeFilters; - private Map> serviceFilters; - protected List properties; - private Map interfaces; + protected List additionalInformation; + protected List properties; + private ComponentMetadataDefinition componentMetadataDefinition; + private Map artifacts; + private Map deploymentArtifacts; + private Map toscaArtifacts; + private List categories; + private List componentInstances; + private List componentInstancesRelations; + private Map> componentInstancesInputs; + private Map> componentInstancesProperties; + private Map> componentInstancesAttributes; + private Map> capabilities; + private Map> requirements; + private Map> componentInstancesInterfaces; + private List inputs; + private List groups; + private Map policies; + private String derivedFromGenericType; + private String derivedFromGenericVersion; + private String toscaType; + private Map nodeFilterComponents; + private Map> nodeFilters; + private Map> serviceFilters; + private Map interfaces; private List dataTypes; - public List getDataTypes() { - return dataTypes; - } - - public void setDataTypes(List dataTypes) { - this.dataTypes = dataTypes; - } - - public Map getInterfaces() { - return interfaces; - } - - public void setInterfaces(Map interfaces) { - this.interfaces = interfaces; - } - public Component(ComponentMetadataDefinition componentMetadataDefinition) { this.componentMetadataDefinition = componentMetadataDefinition; } - public String getDerivedFromGenericVersion() { - return derivedFromGenericVersion; - } - - public void setDerivedFromGenericVersion(String derivedFromGenericVersion) { - this.derivedFromGenericVersion = derivedFromGenericVersion; - } - - public String getDerivedFromGenericType() { - return derivedFromGenericType; - } - - public void setDerivedFromGenericType(String derivedFromGenericType) { - this.derivedFromGenericType = derivedFromGenericType; - } - - @JsonIgnore public ComponentMetadataDefinition getComponentMetadataDefinition() { return componentMetadataDefinition; } - public Map getArtifacts() { - return artifacts; - } - - public void setArtifacts(Map artifacts) { - this.artifacts = artifacts; - } - - public Map getToscaArtifacts() { - return toscaArtifacts; - } - - public void setToscaArtifacts(Map toscaArtifacts) { - this.toscaArtifacts = toscaArtifacts; + @Override + public String getUniqueId() { + return componentMetadataDefinition.getMetadataDataDefinition().getUniqueId(); } - @Override - public String getUniqueId() { - return componentMetadataDefinition.getMetadataDataDefinition().getUniqueId(); - } - public void setUniqueId(String uniqueId) { componentMetadataDefinition.getMetadataDataDefinition().setUniqueId(uniqueId); } - public void setName(String name) { - componentMetadataDefinition.getMetadataDataDefinition().setName(name); - } - - public void setVersion(String version) { - componentMetadataDefinition.getMetadataDataDefinition().setVersion(version); - } - public void setHighestVersion(Boolean isHighestVersion) { componentMetadataDefinition.getMetadataDataDefinition().setHighestVersion(isHighestVersion); } - public void setCreationDate(Long creationDate) { - componentMetadataDefinition.getMetadataDataDefinition().setCreationDate(creationDate); - } - - public void setLastUpdateDate(Long lastUpdateDate) { - componentMetadataDefinition.getMetadataDataDefinition().setLastUpdateDate(lastUpdateDate); - } - - public void setDescription(String description) { - componentMetadataDefinition.getMetadataDataDefinition().setDescription(description); - } - public void setState(LifecycleStateEnum state) { componentMetadataDefinition.getMetadataDataDefinition().setState(state.name()); } - public void setTags(List tags) { - componentMetadataDefinition.getMetadataDataDefinition().setTags(tags); - } - - public void setConformanceLevel(String conformanceLevel) { - componentMetadataDefinition.getMetadataDataDefinition().setConformanceLevel(conformanceLevel); - } - - public void setIcon(String icon) { - componentMetadataDefinition.getMetadataDataDefinition().setIcon(icon); - } - - public void setContactId(String contactId) { - componentMetadataDefinition.getMetadataDataDefinition().setContactId(contactId); - } - public String getCreatorUserId() { return this.componentMetadataDefinition.getMetadataDataDefinition().getCreatorUserId(); } @@ -224,15 +145,23 @@ public abstract class Component implements PropertiesOwner { this.componentMetadataDefinition.getMetadataDataDefinition().setLastUpdaterFullName(lastUpdaterFullName); } - @Override - public String getName() { - return componentMetadataDefinition.getMetadataDataDefinition().getName(); - } + @Override + public String getName() { + return componentMetadataDefinition.getMetadataDataDefinition().getName(); + } + + public void setName(String name) { + componentMetadataDefinition.getMetadataDataDefinition().setName(name); + } public String getVersion() { return componentMetadataDefinition.getMetadataDataDefinition().getVersion(); } + public void setVersion(String version) { + componentMetadataDefinition.getMetadataDataDefinition().setVersion(version); + } + public Boolean isHighestVersion() { return componentMetadataDefinition.getMetadataDataDefinition().isHighestVersion(); } @@ -241,57 +170,76 @@ public abstract class Component implements PropertiesOwner { return componentMetadataDefinition.getMetadataDataDefinition().getCreationDate(); } + public void setCreationDate(Long creationDate) { + componentMetadataDefinition.getMetadataDataDefinition().setCreationDate(creationDate); + } + public Long getLastUpdateDate() { return componentMetadataDefinition.getMetadataDataDefinition().getLastUpdateDate(); } + public void setLastUpdateDate(Long lastUpdateDate) { + componentMetadataDefinition.getMetadataDataDefinition().setLastUpdateDate(lastUpdateDate); + } + public String getDescription() { return componentMetadataDefinition.getMetadataDataDefinition().getDescription(); } + public void setDescription(String description) { + componentMetadataDefinition.getMetadataDataDefinition().setDescription(description); + } + public LifecycleStateEnum getLifecycleState() { if (componentMetadataDefinition.getMetadataDataDefinition().getState() != null) { return LifecycleStateEnum.valueOf(componentMetadataDefinition.getMetadataDataDefinition().getState()); - } - else { + } else { return null; } } + public void setLifecycleState(LifecycleStateEnum state) { + if (state != null) { + this.componentMetadataDefinition.getMetadataDataDefinition().setState(state.name()); + } + } + public List getTags() { return componentMetadataDefinition.getMetadataDataDefinition().getTags(); } + public void setTags(List tags) { + componentMetadataDefinition.getMetadataDataDefinition().setTags(tags); + } + public String getConformanceLevel() { return componentMetadataDefinition.getMetadataDataDefinition().getConformanceLevel(); } + public void setConformanceLevel(String conformanceLevel) { + componentMetadataDefinition.getMetadataDataDefinition().setConformanceLevel(conformanceLevel); + } + public String getIcon() { return componentMetadataDefinition.getMetadataDataDefinition().getIcon(); } + public void setIcon(String icon) { + componentMetadataDefinition.getMetadataDataDefinition().setIcon(icon); + } + public String getContactId() { return componentMetadataDefinition.getMetadataDataDefinition().getContactId(); } - public List getInputs() { - return inputs; + public void setContactId(String contactId) { + componentMetadataDefinition.getMetadataDataDefinition().setContactId(contactId); } public List safeGetInputs() { return inputs == null ? new ArrayList<>() : inputs; } - public void setInputs(List inputs) { - this.inputs = inputs; - } - - public void setLifecycleState(LifecycleStateEnum state) { - if (state != null) { - this.componentMetadataDefinition.getMetadataDataDefinition().setState(state.name()); - } - } - public String getUUID() { return componentMetadataDefinition.getMetadataDataDefinition().getUUID(); } @@ -300,28 +248,20 @@ public abstract class Component implements PropertiesOwner { componentMetadataDefinition.getMetadataDataDefinition().setUUID(uUID); } - public void setSystemName(String systemName) { - componentMetadataDefinition.getMetadataDataDefinition().setSystemName(systemName); - } - public String getSystemName() { return componentMetadataDefinition.getMetadataDataDefinition().getSystemName(); } - public void setAllVersions(Map allVersions) { - componentMetadataDefinition.getMetadataDataDefinition().setAllVersions(allVersions); + public void setSystemName(String systemName) { + componentMetadataDefinition.getMetadataDataDefinition().setSystemName(systemName); } public Map getAllVersions() { return componentMetadataDefinition.getMetadataDataDefinition().getAllVersions(); } - public Map getDeploymentArtifacts() { - return deploymentArtifacts; - } - - public void setDeploymentArtifacts(Map deploymentArtifacts) { - this.deploymentArtifacts = deploymentArtifacts; + public void setAllVersions(Map allVersions) { + componentMetadataDefinition.getMetadataDataDefinition().setAllVersions(allVersions); } public Map getAllArtifacts() { @@ -331,27 +271,11 @@ public abstract class Component implements PropertiesOwner { return allArtifacts; } - Optional getArtifact(String id) { - HashMap allArtifacts = new HashMap<>(); - allArtifacts.putAll(Optional.ofNullable(this.artifacts).orElse(emptyMap())); - allArtifacts.putAll(Optional.ofNullable(this.deploymentArtifacts).orElse(emptyMap())); - allArtifacts.putAll(Optional.ofNullable(this.toscaArtifacts).orElse(emptyMap())); - return Optional.ofNullable(allArtifacts.get(id)); - } - - public List getCategories() { - return categories; - } - - public void setCategories(List categories) { - this.categories = categories; + @Override + public String getNormalizedName() { + return componentMetadataDefinition.getMetadataDataDefinition().getNormalizedName(); } - @Override - public String getNormalizedName() { - return componentMetadataDefinition.getMetadataDataDefinition().getNormalizedName(); - } - public void setNormalizedName(String normalizedName) { componentMetadataDefinition.getMetadataDataDefinition().setNormalizedName(normalizedName); } @@ -371,28 +295,12 @@ public abstract class Component implements PropertiesOwner { return capabilities; } - public void setCapabilities(Map> capabilities) { - this.capabilities = capabilities; - } - - public Map> getRequirements() { - return requirements; - } - - public void setRequirements(Map> requirements) { - this.requirements = requirements; - } - - public List getComponentInstances() { - return componentInstances; - } - public List safeGetComponentInstances() { - if(componentInstances != null) { - return componentInstances; - }else { - return emptyList(); - } + if (componentInstances != null) { + return componentInstances; + } else { + return emptyList(); + } } public Optional fetchInstanceById(String instanceId) { @@ -401,38 +309,31 @@ public abstract class Component implements PropertiesOwner { public Map safeGetComponentInstanceDeploymentArtifacts(String componentInstanceId) { return getComponentInstanceById(componentInstanceId).map(ComponentInstance::safeGetDeploymentArtifacts) - .orElse(emptyMap()); + .orElse(emptyMap()); } public Map safeGetComponentInstanceInformationalArtifacts(String componentInstanceId) { return getComponentInstanceById(componentInstanceId).map(ComponentInstance::safeGetInformationalArtifacts) - .orElse(emptyMap()); + .orElse(emptyMap()); } public List safeGetComponentInstanceHeatArtifacts(String componentInstanceId) { return safeGetComponentInstanceDeploymentArtifacts(componentInstanceId) - .values() - .stream() - .filter(artifact -> ArtifactTypeEnum.HEAT_ENV.name().equals(artifact.getArtifactType())) - .collect(Collectors.toList()); - } - - public void setComponentInstances(List resourceInstances) { - this.componentInstances = resourceInstances; - } - - public List getComponentInstancesRelations() { - return componentInstancesRelations; - } - - public void setComponentInstancesRelations(List resourceInstancesRelations) { - this.componentInstancesRelations = resourceInstancesRelations; + .values() + .stream() + .filter(artifact -> ArtifactTypeEnum.HEAT_ENV.name().equals(artifact.getArtifactType())) + .collect(Collectors.toList()); } public Map> getComponentInstancesProperties() { return componentInstancesProperties; } + public void setComponentInstancesProperties( + Map> resourceInstancesProperties) { + this.componentInstancesProperties = resourceInstancesProperties; + } + public Map> safeGetComponentInstancesProperties() { return componentInstancesProperties == null ? emptyMap() : componentInstancesProperties; } @@ -441,14 +342,14 @@ public abstract class Component implements PropertiesOwner { return componentInstancesProperties == null ? emptyMap() : findUiComponentInstancesProperties(); } - private Map> findUiComponentInstancesProperties() { + private Map> findUiComponentInstancesProperties() { List instancesFromUi = componentInstances.stream() - .filter(i->!i.isCreatedFromCsar()) - .map(ComponentInstance::getUniqueId) - .collect(Collectors.toList()); + .filter(i -> !i.isCreatedFromCsar()) + .map(ComponentInstance::getUniqueId) + .collect(Collectors.toList()); return componentInstancesProperties.entrySet().stream() - .filter(e -> instancesFromUi.contains(e.getKey())) - .collect(Collectors.toMap(e->e.getKey(), e->e.getValue())); + .filter(e -> instancesFromUi.contains(e.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } public Map> safeGetComponentInstancesInputs() { @@ -459,14 +360,14 @@ public abstract class Component implements PropertiesOwner { return componentInstancesInputs == null ? emptyMap() : findUiComponentInstancesInputs(); } - private Map> findUiComponentInstancesInputs() { + private Map> findUiComponentInstancesInputs() { List instancesFromUi = componentInstances.stream() - .filter(i->!i.isCreatedFromCsar()) - .map(ComponentInstance::getUniqueId) - .collect(Collectors.toList()); + .filter(i -> !i.isCreatedFromCsar()) + .map(ComponentInstance::getUniqueId) + .collect(Collectors.toList()); return componentInstancesInputs.entrySet().stream() - .filter(e -> instancesFromUi.contains(e.getKey())) - .collect(Collectors.toMap(e->e.getKey(), e->e.getValue())); + .filter(e -> instancesFromUi.contains(e.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } public List safeGetComponentInstanceProperties(String cmptInstacneId) { @@ -477,14 +378,9 @@ public abstract class Component implements PropertiesOwner { return this.safeGetComponentInstanceEntity(comptInstanceId, this.componentInstancesInputs); } - public List safeGetComponentInstanceInterfaces(String cmptInstacneId) { - return this.safeGetComponentInstanceEntity(cmptInstacneId, this.componentInstancesInterfaces); - } - - public void setComponentInstancesProperties( - Map> resourceInstancesProperties) { - this.componentInstancesProperties = resourceInstancesProperties; - } + public List safeGetComponentInstanceInterfaces(String cmptInstacneId) { + return this.safeGetComponentInstanceEntity(cmptInstacneId, this.componentInstancesInterfaces); + } public Boolean getIsDeleted() { return componentMetadataDefinition.getMetadataDataDefinition().isDeleted(); @@ -549,10 +445,6 @@ public abstract class Component implements PropertiesOwner { return componentInstances.stream().filter(predicate).findFirst(); } - public List getGroups() { - return groups; - } - public List safeGetGroups() { return groups == null ? emptyList() : groups; } @@ -574,259 +466,32 @@ public abstract class Component implements PropertiesOwner { return Optional.empty(); } return groups.stream() - .filter(predicate) - .findAny(); - } - - public Map> getComponentInstancesInterfaces() { - return componentInstancesInterfaces; - } - - public void setComponentInstancesInterfaces(Map> componentInstancesInterfaces) { - this.componentInstancesInterfaces = componentInstancesInterfaces; - } - - public void setGroups(List groups) { - this.groups = groups; - } - - public void addGroups(List groupsToAdd) { - if (groups == null) { - groups = new ArrayList<>(); + .filter(predicate) + .findAny(); } - groups.addAll(groupsToAdd); - } - public Map getPolicies() { - return policies; - } - - public void setPolicies(Map policies) { - this.policies = policies; + public void addGroups(List groupsToAdd) { + if (groups == null) { + groups = new ArrayList<>(); + } + groups.addAll(groupsToAdd); } public void addPolicy(PolicyDefinition policyDefinition) { - if(MapUtils.isEmpty(this.policies)) { - this.policies = new HashMap<>(); + if (MapUtils.isEmpty(this.policies)) { + this.policies = new HashMap<>(); } this.policies.put(policyDefinition.getUniqueId(), policyDefinition); } - public Map getNodeFilterComponents() { - return nodeFilterComponents; - } - - public void setNodeFilterComponents(Map nodeFilter) { - this.nodeFilterComponents = nodeFilter; - } - - - - public Map> getNodeFilters() { - return nodeFilters; - } - - public void setNodeFilters( - Map> nodeFilters) { - this.nodeFilters = nodeFilters; - } - - public Map> getServiceFilters() { - return serviceFilters; - } - - public void setServiceFilters( - Map> serviceFilters) { - this.serviceFilters = serviceFilters; - } - - public List getProperties() { - return properties; - } - - public void setProperties(List properties) { - this.properties = properties; - } - - public void addProperty(PropertyDefinition propertyDefinition) { - if(org.apache.commons.collections.CollectionUtils.isEmpty(this.properties)) { - this.properties = new ArrayList<>(); - } - - this.properties.add(propertyDefinition);; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((artifacts == null) ? 0 : artifacts.hashCode()); - result = prime * result + ((categories == null) ? 0 : categories.hashCode()); - result = prime * result + ((componentMetadataDefinition == null) ? 0 : componentMetadataDefinition.hashCode()); - result = prime * result + ((deploymentArtifacts == null) ? 0 : deploymentArtifacts.hashCode()); - result = prime * result + ((capabilities == null) ? 0 : capabilities.hashCode()); - result = prime * result + ((requirements == null) ? 0 : requirements.hashCode()); - result = prime * result + ((componentInstances == null) ? 0 : componentInstances.hashCode()); - result = prime * result - + ((componentInstancesProperties == null) ? 0 : componentInstancesProperties.hashCode()); - result = prime * result - + ((componentInstancesAttributes == null) ? 0 : componentInstancesAttributes.hashCode()); - result = prime * result + ((componentInstancesInputs == null) ? 0 : componentInstancesInputs.hashCode()); - result = prime * result + ((componentInstancesRelations == null) ? 0 : componentInstancesRelations.hashCode()); - result = prime * result + ((groups == null) ? 0 : groups.hashCode()); - result = prime * result + ((policies == null) ? 0 : policies.hashCode()); - result = prime * result + ((derivedFromGenericType == null) ? 0 : derivedFromGenericType.hashCode()); - result = prime * result + ((derivedFromGenericVersion == null) ? 0 : derivedFromGenericVersion.hashCode()); - result = prime * result + ((interfaces == null) ? 0 : interfaces.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Component other = (Component) obj; - if (artifacts == null) { - if (other.artifacts != null) { - return false; - } - } - else if (!artifacts.equals(other.artifacts)) { - return false; - } - if (categories == null) { - if (other.categories != null) { - return false; - } - } - else if (!categories.equals(other.categories)) { - return false; - } - if (componentMetadataDefinition == null) { - if (other.componentMetadataDefinition != null) { - return false; - } - } - else if (!componentMetadataDefinition.equals(other.componentMetadataDefinition)) { - return false; - } - - if (deploymentArtifacts == null) { - if (other.deploymentArtifacts != null) { - return false; - } - } - else if (!deploymentArtifacts.equals(other.deploymentArtifacts)) { - return false; + public void addProperty(PropertyDefinition propertyDefinition) { + if (org.apache.commons.collections.CollectionUtils.isEmpty(this.properties)) { + this.properties = new ArrayList<>(); } - if (componentInstances == null) { - if (other.componentInstances != null) { - return false; - } - } - else if (!componentInstances.equals(other.componentInstances)) { - return false; - } - if (componentInstancesProperties == null) { - if (other.componentInstancesProperties != null) { - return false; - } - } - else if (!componentInstancesProperties.equals(other.componentInstancesProperties)) { - return false; - } - - if (!Objects.equals(componentInstancesAttributes, other.componentInstancesAttributes)) { - return false; - } - if (!Objects.equals(componentInstancesInputs, other.componentInstancesInputs)) { - return false; - } - if (componentInstancesRelations == null) { - if (other.componentInstancesRelations != null) { - return false; - } - } - else if (!componentInstancesRelations.equals(other.componentInstancesRelations)) { - return false; - } - if (requirements == null) { - if (other.requirements != null) { - return false; - } - } - else if (!requirements.equals(other.requirements)) { - return false; - } - if (capabilities == null) { - if (other.capabilities != null) { - return false; - } - } - else if (!capabilities.equals(other.capabilities)) { - return false; - } - if (groups == null) { - if (other.groups != null) { - return false; - } - } - else if (!groups.equals(other.groups)) { - return false; - } - if (policies == null) { - if (other.policies != null) { - return false; - } - } - else if (!policies.equals(other.policies)) { - return false; - } - if (derivedFromGenericType == null) { - if (other.derivedFromGenericType != null) { - return false; - } - } - else if (!derivedFromGenericType.equals(other.derivedFromGenericType)) { - return false; - } - if (derivedFromGenericVersion == null) { - if (other.derivedFromGenericVersion != null) { - return false; - } - } - else if (!derivedFromGenericVersion.equals(other.derivedFromGenericVersion)) { - return false; - } - if (interfaces == null) { - if (other.interfaces != null) { - return false; - } - } - else if (!interfaces.equals(other.interfaces)) { - return false; - } - if (properties == null) { - if (other.properties != null) { - return false; - } - } - else if (!properties.equals(other.properties)) { - return false; - } - else if (!nodeFilterComponents.equals(other.nodeFilterComponents)) { - return false; - } - return true; + this.properties.add(propertyDefinition); + ; } public void addCategory(String category, String subCategory) { @@ -903,27 +568,14 @@ public abstract class Component implements PropertiesOwner { } } - public Map> getComponentInstancesAttributes() { - return componentInstancesAttributes; - } - - public void setComponentInstancesAttributes( - Map> componentInstancesAttributes) { - this.componentInstancesAttributes = componentInstancesAttributes; - } - - public Map> getComponentInstancesInputs() { - return componentInstancesInputs; - } - public Map> safeGetGroupsProperties() { if (isEmpty(groups)) { return emptyMap(); } return groups.stream() - .filter(gr -> Objects.nonNull(gr.getProperties())) - .collect(toMap(GroupDataDefinition::getUniqueId, - GroupDataDefinition::getProperties)); + .filter(gr -> Objects.nonNull(gr.getProperties())) + .collect(toMap(GroupDataDefinition::getUniqueId, + GroupDataDefinition::getProperties)); } public Map> safeGetPolicyProperties() { @@ -931,10 +583,10 @@ public abstract class Component implements PropertiesOwner { return emptyMap(); } return policies.values() - .stream() - .filter(policy -> Objects.nonNull(policy.getProperties())) - .collect(toMap(PolicyDataDefinition::getUniqueId, - PolicyDataDefinition::getProperties)); + .stream() + .filter(policy -> Objects.nonNull(policy.getProperties())) + .collect(toMap(PolicyDataDefinition::getUniqueId, + PolicyDataDefinition::getProperties)); } public List safeGetComponentInstanceInputsByName(String cmptInstanceName) { @@ -943,11 +595,11 @@ public abstract class Component implements PropertiesOwner { return emptyPropsList; } return this.componentInstances.stream() - .filter(ci -> ci.getName().equals(cmptInstanceName)) - .map(ComponentInstance::getUniqueId) - .map(instanceId -> safeGetComponentInstanceEntity(instanceId, this.componentInstancesInputs)) - .findAny() - .orElse(emptyPropsList); + .filter(ci -> ci.getName().equals(cmptInstanceName)) + .map(ComponentInstance::getUniqueId) + .map(instanceId -> safeGetComponentInstanceEntity(instanceId, this.componentInstancesInputs)) + .findAny() + .orElse(emptyPropsList); } private List safeGetComponentInstanceEntity(String cmptInstanceId, Map> instanceEntities) { @@ -959,25 +611,16 @@ public abstract class Component implements PropertiesOwner { return cmptInstanceProps == null ? emptyPropsList : cmptInstanceProps; } - - public void setComponentInstancesInputs(Map> componentInstancesInputs) { - this.componentInstancesInputs = componentInstancesInputs; - } - public void setSpecificComponetTypeArtifacts(Map specificComponentTypeArtifacts) { // Implement where needed } - public void setMetadataDefinition(ComponentMetadataDefinition metadataDefinition) { - this.componentMetadataDefinition = metadataDefinition; - } - public String fetchGenericTypeToscaNameFromConfig() { // Implement where needed return ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getGenericAssetNodeTypes() - .get(this.assetType()); + .getConfiguration() + .getGenericAssetNodeTypes() + .get(this.assetType()); } public String assetType() { @@ -1004,22 +647,6 @@ public abstract class Component implements PropertiesOwner { return ToscaElementTypeEnum.TOPOLOGY_TEMPLATE.getValue().equals(toscaType); } - public String getToscaType() { - return toscaType; - } - - public void setToscaType(String toscaType) { - this.toscaType = toscaType; - } - - public List getAdditionalInformation() { - return additionalInformation; - } - - public void setAdditionalInformation(List additionalInformation) { - this.additionalInformation = additionalInformation; - } - public PolicyDefinition getPolicyById(String id) { return policies != null ? policies.get(id) : null; } @@ -1041,8 +668,8 @@ public abstract class Component implements PropertiesOwner { return emptyList(); } return policies.values().stream() - .filter(policyPredicate) - .collect(Collectors.toList()); + .filter(policyPredicate) + .collect(Collectors.toList()); } public List resolveGroupsByMember(String instanceId) { @@ -1050,36 +677,47 @@ public abstract class Component implements PropertiesOwner { return emptyList(); } return groups.stream() - .filter(group -> group.containsInstanceAsMember(instanceId)) - .collect(Collectors.toList()); + .filter(group -> group.containsInstanceAsMember(instanceId)) + .collect(Collectors.toList()); } public String getActualComponentType() { return componentMetadataDefinition.getMetadataDataDefinition().getActualComponentType(); } - public Boolean isArchived() { return componentMetadataDefinition.getMetadataDataDefinition().isArchived(); } + public Boolean isArchived() { + return componentMetadataDefinition.getMetadataDataDefinition().isArchived(); + } - public void setArchived(Boolean archived) { componentMetadataDefinition.getMetadataDataDefinition().setArchived(archived); } + public void setArchived(Boolean archived) { + componentMetadataDefinition.getMetadataDataDefinition().setArchived(archived); + } - public Long getArchiveTime() { return componentMetadataDefinition.getMetadataDataDefinition().getArchiveTime(); } + public Long getArchiveTime() { + return componentMetadataDefinition.getMetadataDataDefinition().getArchiveTime(); + } - public void setArchiveTime(Long archiveTime) { componentMetadataDefinition.getMetadataDataDefinition().setArchiveTime(archiveTime); } + public void setArchiveTime(Long archiveTime) { + componentMetadataDefinition.getMetadataDataDefinition().setArchiveTime(archiveTime); + } - public Boolean isVspArchived() { return componentMetadataDefinition.getMetadataDataDefinition().isVspArchived(); } + public Boolean isVspArchived() { + return componentMetadataDefinition.getMetadataDataDefinition().isVspArchived(); + } - public void setVspArchived(Boolean vspArchived) { componentMetadataDefinition.getMetadataDataDefinition().setVspArchived(vspArchived); } + public void setVspArchived(Boolean vspArchived) { + componentMetadataDefinition.getMetadataDataDefinition().setVspArchived(vspArchived); + } //supportability log method return map of component metadata teddy.h - public Map getComponentMetadataForSupportLog(){ - MapcomponentMetadata=new HashMap<>(); - componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_NAME,this.getName()); - componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_VERSION,this.getVersion()); - componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_UUID,this.getUUID()); - componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_UUID,this.getCsarUUID()); - componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_VERSION,this.getCsarVersion()); + public Map getComponentMetadataForSupportLog() { + Map componentMetadata = new HashMap<>(); + componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_NAME, this.getName()); + componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_VERSION, this.getVersion()); + componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_UUID, this.getUUID()); + componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_UUID, this.getCsarUUID()); + componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_VERSION, this.getCsarVersion()); return componentMetadata; } - } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Product.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Product.java index 66062cf5f2..b08df77922 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Product.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Product.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,11 +20,10 @@ package org.openecomp.sdc.be.model; +import java.util.List; import org.openecomp.sdc.be.datatypes.elements.ProductMetadataDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import java.util.List; - public class Product extends Component { public Product() { @@ -45,10 +44,12 @@ public class Product extends Component { getProductMetadataDefinition().setFullName(fullName); } + @Override public String getInvariantUUID() { return getProductMetadataDefinition().getInvariantUUID(); } + @Override public void setInvariantUUID(String invariantUUID) { getProductMetadataDefinition().setInvariantUUID(invariantUUID); } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/RequirementDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/RequirementDefinition.java index d2400a7e14..acc7452ab4 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/RequirementDefinition.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/RequirementDefinition.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. @@ -27,7 +27,7 @@ import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition; */ public class RequirementDefinition extends RequirementDataDefinition { - public RequirementDefinition(){ + public RequirementDefinition() { super(); } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.java index e5122aacf3..1338fb1c80 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.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,159 +20,153 @@ package org.openecomp.sdc.be.model; -import org.apache.commons.lang.StringUtils; -import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition; import java.util.HashMap; import java.util.Map; - +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import org.apache.commons.lang.StringUtils; +import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition; import org.openecomp.sdc.be.datatypes.components.ServiceMetadataDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.InstantiationTypes; import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElementTypeEnum; +@Getter +@Setter +@EqualsAndHashCode public class Service extends Component { + private Map serviceApiArtifacts; + private Map forwardingPaths; + public Service() { super(new ServiceMetadataDefinition()); this.getComponentMetadataDefinition().getMetadataDataDefinition().setComponentType(ComponentTypeEnum.SERVICE); this.setToscaType(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE.getValue()); } - public Service(ComponentMetadataDefinition serviceMetadataDefinition) { - super(serviceMetadataDefinition); - ComponentMetadataDataDefinition metadataDataDefinition = this.getComponentMetadataDefinition().getMetadataDataDefinition(); - if(metadataDataDefinition != null) { - metadataDataDefinition.setComponentType(ComponentTypeEnum.SERVICE); - } - this.setToscaType(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE.getValue()); - } - - private Map serviceApiArtifacts; - private Map forwardingPaths; - - public Map getServiceApiArtifacts() { - return serviceApiArtifacts; - } - - public void setServiceApiArtifacts(Map serviceApiArtifacts) { - this.serviceApiArtifacts = serviceApiArtifacts; - } - - public String getProjectCode() { - return getServiceMetadataDefinition().getProjectCode(); - } - - public Map getForwardingPaths() { - return forwardingPaths; - } - - public void setForwardingPaths(Map forwardingPaths) { - this.forwardingPaths = forwardingPaths; - } - - public ForwardingPathDataDefinition addForwardingPath(ForwardingPathDataDefinition forwardingPathDataDefinition){ - if(forwardingPaths == null){ - forwardingPaths = new HashMap<>(); - } - return forwardingPaths.put(forwardingPathDataDefinition.getUniqueId(),forwardingPathDataDefinition); - } - - public void setProjectCode(String projectName) { - getServiceMetadataDefinition().setProjectCode(projectName); - } - - public DistributionStatusEnum getDistributionStatus() { - String distributionStatus = getServiceMetadataDefinition().getDistributionStatus(); - if (distributionStatus != null) { - return DistributionStatusEnum.valueOf(distributionStatus); - } else { - return null; - } - } - - public void setDistributionStatus(DistributionStatusEnum distributionStatus) { - if (distributionStatus != null) - getServiceMetadataDefinition().setDistributionStatus(distributionStatus.name()); - } - - public void setEcompGeneratedNaming(Boolean ecompGeneratedNaming) { - getServiceMetadataDefinition().setEcompGeneratedNaming(ecompGeneratedNaming); - } - - public Boolean isEcompGeneratedNaming() { - return getServiceMetadataDefinition().isEcompGeneratedNaming(); - } - - public void setNamingPolicy(String namingPolicy) { - getServiceMetadataDefinition().setNamingPolicy(namingPolicy); - } - - public String getNamingPolicy() { - return getServiceMetadataDefinition().getNamingPolicy(); - } - - public String getEnvironmentContext() { return getServiceMetadataDefinition().getEnvironmentContext(); } - - public void setEnvironmentContext(String environmentContext) { - getServiceMetadataDefinition().setEnvironmentContext(environmentContext); - } - - public void setServiceType(String serviceType){ - getServiceMetadataDefinition().setServiceType(serviceType); - } - - public String getServiceType(){ - return getServiceMetadataDefinition().getServiceType(); - } - - public void setServiceRole(String serviceRole){ - getServiceMetadataDefinition().setServiceRole(serviceRole); - } - - public String getServiceRole(){ - return getServiceMetadataDefinition().getServiceRole(); - } - - public void setInstantiationType(String instantiationType){ - getServiceMetadataDefinition().setInstantiationType(instantiationType); - } - - public String getInstantiationType(){ - return getServiceMetadataDefinition().getInstantiationType(); - } - - private ServiceMetadataDataDefinition getServiceMetadataDefinition() { - return (ServiceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition(); - } - - public void setServiceFunction(String serviceFunction){ - getServiceMetadataDefinition().setServiceFunction(serviceFunction); - } - - public String getServiceFunction(){ - return getServiceMetadataDefinition().getServiceFunction(); - } - - public void validateAndSetInstantiationType() { - if (this.getInstantiationType().equals(StringUtils.EMPTY)) { - this.setInstantiationType(InstantiationTypes.A_LA_CARTE.getValue()); - } - } - - - @Override - public String toString() { - return "Service [componentMetadataDefinition=" + getComponentMetadataDefinition() - // + ", resourceInstances=" + resourceInstances + ", - // resourceInstancesRelations=" + resourceInstancesRelations + ", - // resourceInstancesRelations=" - // + resourceInstancesRelations - + " ]"; - } - - @Override - public void setSpecificComponetTypeArtifacts(Map specificComponentTypeArtifacts) { - setServiceApiArtifacts(specificComponentTypeArtifacts); - } + public Service(ComponentMetadataDefinition serviceMetadataDefinition) { + super(serviceMetadataDefinition); + ComponentMetadataDataDefinition metadataDataDefinition = this.getComponentMetadataDefinition() + .getMetadataDataDefinition(); + if (metadataDataDefinition != null) { + metadataDataDefinition.setComponentType(ComponentTypeEnum.SERVICE); + } + this.setToscaType(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE.getValue()); + } + + @Override + public String getProjectCode() { + return getServiceMetadataDefinition().getProjectCode(); + } + + @Override + public void setProjectCode(String projectName) { + getServiceMetadataDefinition().setProjectCode(projectName); + } + + public ForwardingPathDataDefinition addForwardingPath(ForwardingPathDataDefinition forwardingPathDataDefinition) { + if (forwardingPaths == null) { + forwardingPaths = new HashMap<>(); + } + return forwardingPaths.put(forwardingPathDataDefinition.getUniqueId(), forwardingPathDataDefinition); + } + + public DistributionStatusEnum getDistributionStatus() { + String distributionStatus = getServiceMetadataDefinition().getDistributionStatus(); + if (distributionStatus != null) { + return DistributionStatusEnum.valueOf(distributionStatus); + } else { + return null; + } + } + + public void setDistributionStatus(DistributionStatusEnum distributionStatus) { + if (distributionStatus != null) { + getServiceMetadataDefinition().setDistributionStatus(distributionStatus.name()); + } + } + + public void setEcompGeneratedNaming(Boolean ecompGeneratedNaming) { + getServiceMetadataDefinition().setEcompGeneratedNaming(ecompGeneratedNaming); + } + + public Boolean isEcompGeneratedNaming() { + return getServiceMetadataDefinition().isEcompGeneratedNaming(); + } + + public String getNamingPolicy() { + return getServiceMetadataDefinition().getNamingPolicy(); + } + + public void setNamingPolicy(String namingPolicy) { + getServiceMetadataDefinition().setNamingPolicy(namingPolicy); + } + + public String getEnvironmentContext() { + return getServiceMetadataDefinition().getEnvironmentContext(); + } + + public void setEnvironmentContext(String environmentContext) { + getServiceMetadataDefinition().setEnvironmentContext(environmentContext); + } + + public String getServiceType() { + return getServiceMetadataDefinition().getServiceType(); + } + + public void setServiceType(String serviceType) { + getServiceMetadataDefinition().setServiceType(serviceType); + } + + public String getServiceRole() { + return getServiceMetadataDefinition().getServiceRole(); + } + + public void setServiceRole(String serviceRole) { + getServiceMetadataDefinition().setServiceRole(serviceRole); + } + + public String getInstantiationType() { + return getServiceMetadataDefinition().getInstantiationType(); + } + + public void setInstantiationType(String instantiationType) { + getServiceMetadataDefinition().setInstantiationType(instantiationType); + } + + private ServiceMetadataDataDefinition getServiceMetadataDefinition() { + return (ServiceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition(); + } + + public String getServiceFunction() { + return getServiceMetadataDefinition().getServiceFunction(); + } + + public void setServiceFunction(String serviceFunction) { + getServiceMetadataDefinition().setServiceFunction(serviceFunction); + } + + public void validateAndSetInstantiationType() { + if (this.getInstantiationType().equals(StringUtils.EMPTY)) { + this.setInstantiationType(InstantiationTypes.A_LA_CARTE.getValue()); + } + } + + @Override + public String toString() { + return "Service [componentMetadataDefinition=" + getComponentMetadataDefinition() + // + ", resourceInstances=" + resourceInstances + ", + // resourceInstancesRelations=" + resourceInstancesRelations + ", + // resourceInstancesRelations=" + // + resourceInstancesRelations + + " ]"; + } + + @Override + public void setSpecificComponetTypeArtifacts(Map specificComponentTypeArtifacts) { + setServiceApiArtifacts(specificComponentTypeArtifacts); + } } -- cgit 1.2.3-korg