Default gateway value to NULL when not present 86/107686/1
authorSmokowski, Steven <steve.smokowski@att.com>
Thu, 14 May 2020 13:54:38 +0000 (09:54 -0400)
committerBenjamin, Max (mb388a) <mb388a@att.com>
Thu, 14 May 2020 13:54:39 +0000 (09:54 -0400)
Default gateway value to NULL when not present

Issue-ID: SO-2934
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I7a9839817887575ec425e2ae6f1782b94f0bb907

bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java
bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/l3-network-multiple-subnets.json

index 3f81e43..e317822 100644 (file)
@@ -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
index ccd4376..7ff7848 100644 (file)
@@ -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<org.onap.so.openstack.beans.HostRoute>());
 
         List<org.onap.so.openstack.beans.Subnet> 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());
     }
 }
index e9b25ff..21df571 100644 (file)
                        "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