diff options
author | Mnushkin, Dmitry <dmitry.mnushkin@att.com> | 2020-05-16 12:11:13 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@att.com> | 2020-05-18 17:45:54 -0400 |
commit | baa54fed71ccc2e66bcd9ffbd9e6e59c2840e787 (patch) | |
tree | 25a5e5dd90611ea1d779d68c4d60d58e6e6ab43c /adapters/mso-openstack-adapters/src/main/java | |
parent | 959d27a96f24cf74dfa3764df64b65a1ba9b9cbb (diff) |
add null check for server HostName/Name/Flavor
add null check for server HostName/Name/Flavor
maven format file after build failure
include relationship empty string verification
add unit test to verify null/empty string
update empty string validation code
Issue-ID: SO-2912
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: If308469cd4ec0008a6d1a480641da890d67b4259
Diffstat (limited to 'adapters/mso-openstack-adapters/src/main/java')
-rw-r--r-- | adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java index eb4b9f538d..6817be8c49 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java @@ -39,6 +39,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.onap.aai.domain.yang.Flavor; import org.onap.aai.domain.yang.Image; import org.onap.aai.domain.yang.PInterface; @@ -77,9 +78,11 @@ public class AaiHelper { List<Relationship> relationships = relationshipList.getRelationship(); // vserver to pserver relationship - Relationship pserverRelationship = buildRelationship( - AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, server.getHypervisorHostname())); - relationships.add(pserverRelationship); + if (!StringUtils.isEmpty(server.getHypervisorHostname())) { + Relationship pserverRelationship = buildRelationship( + AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, server.getHypervisorHostname())); + relationships.add(pserverRelationship); + } // vserver to generic-vnf relationship Relationship genericVnfRelationship = @@ -87,10 +90,11 @@ public class AaiHelper { relationships.add(genericVnfRelationship); // vserver to vnfc relationship - Relationship vnfcRelationship = - buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.VNFC, server.getName())); - relationships.add(vnfcRelationship); - + if (!StringUtils.isEmpty(server.getName())) { + Relationship vnfcRelationship = + buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.VNFC, server.getName())); + relationships.add(vnfcRelationship); + } // vserver to vf-module relationship Relationship vfModuleRelationship = @@ -105,9 +109,12 @@ public class AaiHelper { } // vserver to flavor relationship - Relationship flavorRel = buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.FLAVOR, cloudOwner, - cloudRegionId, server.getFlavor().getId())); - relationships.add(flavorRel); + if (server.getFlavor() != null) { + Relationship flavorRel = buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.FLAVOR, cloudOwner, + cloudRegionId, server.getFlavor().getId())); + relationships.add(flavorRel); + } + return relationshipList; } |