From 7ae772d0115598564a5440f5400ab256252dcc2e Mon Sep 17 00:00:00 2001 From: "Smokowski, Steven" Date: Thu, 14 May 2020 09:54:38 -0400 Subject: Default gateway value to NULL when not present Default gateway value to NULL when not present Issue-ID: SO-2934 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I7a9839817887575ec425e2ae6f1782b94f0bb907 --- .../network/mapper/NetworkAdapterObjectMapper.java | 3 +++ .../mapper/NetworkAdapterObjectMapperTest.java | 3 +++ .../NetworkMapper/l3-network-multiple-subnets.json | 25 ++++++++++++++++++++++ 3 files changed, 31 insertions(+) (limited to 'bpmn/so-bpmn-tasks/src') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java index 3f81e432e1..e317822a13 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java @@ -287,6 +287,9 @@ public class NetworkAdapterObjectMapper { for (org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet subnet : subnets) { org.onap.so.openstack.beans.Subnet openstackSubnet = modelMapper.map(subnet, org.onap.so.openstack.beans.Subnet.class); + if (StringUtils.isEmpty(openstackSubnet.getGatewayIp())) { + openstackSubnet.setGatewayIp("NULL"); + } // update cidr value if (subnet.getNetworkStartAddress() != null && subnet.getCidrMask() != null) openstackSubnet diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java index ccd4376a10..7ff784815b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java @@ -176,6 +176,7 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup { public void updateNetworkRequestMapperTest() throws UnsupportedEncodingException { org.onap.so.openstack.beans.Subnet subnet = new org.onap.so.openstack.beans.Subnet(); subnet.setSubnetId("subnetId"); + subnet.setGatewayIp("NULL"); subnet.setHostRoutes(new ArrayList()); List subnets = new ArrayList<>(); @@ -397,5 +398,7 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup { assertEquals("192.168.0.0/16", subnets.get(0).getHostRoutes().get(0).getPrefix()); assertEquals("192.168.1.5/16", subnets.get(0).getHostRoutes().get(1).getPrefix()); + + assertEquals("NULL", subnets.get(1).getGatewayIp()); } } diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/l3-network-multiple-subnets.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/l3-network-multiple-subnets.json index e9b25ff266..21df57108b 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/l3-network-multiple-subnets.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/l3-network-multiple-subnets.json @@ -49,5 +49,30 @@ "next-hop": "192.168.1.1", "next-hop-type": null }] + }, { + "subnet-id" : "subnetId2", + "subnet-name" : "aSubnetName2", + "neutron-subnet-id" : null, + "network-start-address" : "192.168.1.2", + "cidr-mask" : "10", + "ip-version" : "4", + "orchestration-status" : "ACTIVE", + "dhcp-enabled" : true, + "dhcp-start" : "192.168.1.2", + "dhcp-end" : "192.168.1.16", + "subnet-role" : "", + "ip-assignment-direction" : "true", + "subnet-sequence" : null, + "host-routes": [{ + "host-route-id": "hrId1", + "route-prefix": "192.168.0.0/16", + "next-hop": "192.168.1.1", + "next-hop-type": null + }, { + "host-route-id": "hrId2", + "route-prefix": "192.168.1.5/16", + "next-hop": "192.168.1.1", + "next-hop-type": null + }] }] } \ No newline at end of file -- cgit 1.2.3-korg